﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using System.Data;

namespace DataAccessLayer
{
    public class ChiPhiSanPhamRepository : DataProvider
    {
        public void capnhat(ChiPhiInAnEnt cpia)
        {
            string sql = " update  chiphiinan set dongia ="
                + cpia.Dongia + " where ma = " + cpia.Machiphiinan;
            connect();
            executeNonQuery(sql);
            disConnect();

        }

        public DataTable danhsachchiphiinan()
        {
            DataTable kq = new DataTable();
            string sql_ds = "   select sp.TenSP, cl.TenChatLieu, cp.DonGia, cp.Ma, cp.MauSac , cp.ChieuDai , cp.ChieuRong  "
            + " from sanpham sp, chiphiinan cp, chatlieu cl "
            + " where sp.MaSP  = cp.MaSP and   cl.MaChatLieu = cp.MaChatLieu  ";
            connect();
            kq = executeQueryDataTable(sql_ds);

            disConnect();
            return kq;



        }
        public DataTable danhsachchiphiinan_spTheoTen(string s)
        {
            DataTable kq = new DataTable();
            string sql_ds = "   select sp.TenSP, cl.TenChatLieu, cp.Ma, cp.MauSac , cp.ChieuDai , cp.ChieuRong , cp.DonGia "
            + " from sanpham sp, chiphiinan cp, chatlieu cl "
            + " where sp.MaSP  = cp.MaSP and   cl.MaChatLieu = cp.MaChatLieu "
            + " and sp.TenSP like '%" + s + "%'  ";
            connect();
            kq = executeQueryDataTable(sql_ds);

            disConnect();
            return kq;

        }

    }
}
